<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.joda.org/joda/time/tags" prefix="joda" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<link href="${base}css/apps/report/show.css" media="all"
	rel="stylesheet" type="text/css" />
<%@ include file="../../../jsp/commons/headfiles-jquery.jsp"%>
<script type="text/javascript">
	//var operation='create';
</script>
</head>
<body>
	<div class="navbar navbar-fixed-top navbar-inverse">
		<div class="navbar-inner">
			<div class="container-fluid">
				<div class="nav-collapse">
					<a class="brand" href="#">生产日报表</a>
					<button class="btn btn-primary" id="saveBtn" type="button">
						<i class="icon-ok-sign"></i>保存
					</button>
					<button class="btn btn-success" id="downloadBtn" type="button">
						<i class="icon-arrow-down"></i>下载
					</button>

					<button class="btn btn-warning" id="newPdt" type="button">
						添加常规产品</button>
					<c:if test="${ not empty bean.id}">
						<div class="btn-group">
							<button id="rbtn" class="btn btn-info" type="button">添加科研产品</button>
							<button class="btn dropdown-toggle btn-info" data-toggle="dropdown">
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu">
							   <li><a href="javascript:;">清除<input type="checkbox" id="clearbtn" value="true" onclick="setCleanModel(this);" /></a></li>	
							</ul>
						</div>						
					    <button type="button" class="btn btn-success" onclick="submitfor('${bean.id}',true)" >提交报表</button>
					</c:if>				
					
					<div class="pull-right">
						<button class="btn btn-danger" type="button" onclick="closeMe();">
							<i class="icon-remove-sign"></i>关闭
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>

	<form id="armform">
		<c:if test="${ not empty bean.id}">
			<input type="hidden" id="bean.id" name="bean.id" value="${bean.id}" />
			<script type="text/javascript">
				operation = "update";
			</script>

		</c:if>
		<input type="hidden" name="bean.department.id"
			value="${empty bean.department?loginUser.department.id:bean.department.id}" />
		<input type="hidden" name="bean.maker.username"
			value="${empty bean.maker?loginUser.username:bean.maker.username}" />

		<table width="100%" id="itemlist"
			class="table table-striped table-bordered table-condensed table-hover">
			<caption>
			<joda:format value="${bean.createDate}" pattern="yyyy年 MM 月dd 日  HH:mm:ss 军品生产日报"/>
			</caption>
			<thead>
				<tr>
					<td colspan="5">
					  日期: <joda:format value="${bean.createDate}" pattern="yyyy-MM-dd"/>
					</td>
				</tr>
				<tr>
					<th rowspan="2">代码</th>
					<th rowspan="2">名称</th>
					<th colspan="2" class="number-field">期初结存</th>
					<th rowspan="2" class="number-field">本月计划</th>
					<th colspan="2" class="number-field">动工数</th>
					<th colspan="2" class="number-field">合格数</th>
					<th colspan="2" class="number-field">废品数</th>
					<th colspan="2" class="number-field">试销数</th>
					<th rowspan="2" class="number-field">期末数</th>
					<th rowspan="2">备注</th>
					<th rowspan="2">产品类型</th>
					<th rowspan="2">管理</th>
				</tr>
				<tr>
					<th>年初</th>
					<th>月初</th>
					<th>当日</th>
					<th>累计</th>
					<th>当日</th>
					<th>累计</th>
					<th>当日</th>
					<th>累计</th>
					<th>当日</th>
					<th>累计</th>
				</tr>
			</thead>


			<c:set var="gindex" value="0" scope="request" />
			<%
				org.jackysoft.entity.ProductType[] ptypes = org.jackysoft.entity.ProductType
								.values();
						pageContext.setAttribute("ptypes", ptypes);
			%>

			<tbody id="pdtBody">

				<!-- 常规产品 -->
				<tr>
					<td colspan="18" style="background-color: #bbb"><span
						style="color: 000; font-size: 14px; font-weight: bolder">常规产品</span>

					</td>
				</tr>
				<c:set var="armItems" value="${bean.classifiedItems['常规产品']}" />

				<%@ include file="itemList.jsp"%>
				<tr>
					<td colspan="18">&copy;</td>
				</tr>			

				<!-- 成品-->
				<tr>
					<td colspan="18" style="background-color: #aaa"><span
						style="color: 000; font-size: 14px; font-weight: bolder">厂内配套</span>

					</td>
				</tr>
				<c:set var="armItems" value="${bean.classifiedItems['厂内配套']}" />
				<%@ include file="itemList.jsp"%>
				<tr>
					<td colspan="18">&copy;</td>
				</tr>


				<!-- 半成品 -->
				<tr>
					<td colspan="18" style="background-color: #aaa"><span
						style="color: 000; font-size: 14px; font-weight: bolder">其他</span>

					</td>
				</tr>
				<c:set var="armItems" value="${bean.classifiedItems['其他']}" />
				<%@ include file="itemList.jsp"%>
				<tr>
					<td colspan="18">&copy;</td>
				</tr>

			</tbody>
			<tfoot>
				<tr>
					<td colspan="18">&copy;2011-2012</td>
				</tr>
			</tfoot>

		</table>
	</form>

    <table width="100%" id="itemlist"
			class="table table-condensed table-hover table-bordered">
			<caption>
				科研产品及其他产品
			</caption>
     <thead>
        <tr>
         <th>代码</th>
         <th>名称</th>
         <th>年初</th>
         <th>月初</th>
         <th>今日动工</th>
         <th>动工累计</th>
         <th>今日合格</th>
         <th>合格累计</th>
         <th>今日废品</th>
         <th>废品累计</th>
         <th>今日试销</th>
         <th>试销累计</th>
         <th>期末结存</th>
         <th>备注</th>
         <th>类型</th>
        </tr>
     </thead>
     	<c:set var="armItems" value="${bean.researchItems}" />
		<tbody>
		  <%@ include file="researchItemList.jsp"%>
        </tbody>
    </table>

<div id="debug"></div>
	
	<div class="navbar navbar-fixed-bottom navbar-inverse">
		<div class="navbar-inner">
			<a class="brand" href="#">按代码搜索</a>
			<div class="input-append">
			<input id="scode"/>					
					<button type="button" class="btn btn-primary" onclick="search()">
					  <i class="icon-search"></i>
					</button>
					<button class='btn btn-success' onclick='goNext()'>
					   <i class='icon-arrow-right'></i>
					</button>
		     </div>	
		</div>
	</div>



	<script type="text/javascript">
		var lastrpt = '${bean.last.id}' || false;
		var rptId = '${bean.id}';
		var itemIndex = '${fn:length(bean.armItems)-1}' || 0;
		function testModal(msg) {
			alert(msg);
		}
	</script>


	<script type="text/javascript"
		src="${base}scripts/apps/reporter/edit.js"></script>
	<script type="text/javascript"
		src="${base}scripts/apps/reporter/util.js"></script>
	<script type="text/javascript"
		src="${base}scripts/apps/reporter/daily/edit.js"></script>
	
</body>
</html>